home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / tracker-4.13.lha / tracker / analyzer.c next >
Encoding:
C/C++ Source or Header  |  1995-02-15  |  3.4 KB  |  175 lines

  1. /* analyzer.c 
  2.     vi:ts=3 sw=3:
  3. */
  4.  
  5.  
  6. /* read module files and output statistics on them */
  7.  
  8. /* $Id: analyzer.c,v 4.11 1995/02/15 15:26:21 espie Exp espie $
  9.  * $Log: analyzer.c,v $
  10.  * Revision 4.11  1995/02/15  15:26:21  espie
  11.  * *** empty log message ***
  12.  *
  13.  * Revision 4.10  1995/02/14  04:02:28  espie
  14.  * Nothing.
  15.  *
  16.  * Revision 4.10  1995/02/14  04:02:28  espie
  17.  * Nothing.
  18.  *
  19.  * Revision 4.9  1995/02/06  14:50:47  espie
  20.  * Changed sample_info.
  21.  *
  22.  * Revision 4.9  1995/02/06  14:50:47  espie
  23.  * Changed sample_info.
  24.  *
  25.  * Revision 4.8  1995/02/01  20:41:45  espie
  26.  * *** empty log message ***
  27.  *
  28.  * Revision 4.7  1995/02/01  16:39:04  espie
  29.  * Includes moved to defs.h
  30.  *
  31.  * Revision 4.7  1995/02/01  16:39:04  espie
  32.  * Includes moved to defs.h
  33.  *
  34.  * Revision 4.6  1995/01/28  09:23:59  espie
  35.  * Need (?) a return 0 at the end.
  36.  *
  37.  * Revision 4.1  1994/01/12  16:10:20  espie
  38.  * Fixed up last minute problems.
  39.  * Lots of changes.
  40.  * removed create_note_tables(), run_in_fg().
  41.  * Use new pref scheme.
  42.  * New open_file semantics.
  43.  * Added speed check.
  44.  * Added patch for non termio.
  45.  */
  46.  
  47. #include "defs.h"
  48.  
  49. #include "extern.h"
  50. #include "song.h"
  51. #include "tags.h"
  52. #include "prefs.h"
  53.  
  54. ID("$Id: analyzer.c,v 4.11 1995/02/15 15:26:21 espie Exp espie $")
  55.  
  56. int error;
  57.  
  58. struct song *do_read_song(name, type)
  59. char *name;
  60. int type;
  61.    {
  62.    struct song *song;
  63.    struct exfile *file;
  64.  
  65.    file = open_file(name, "r", getenv("MODPATH"));
  66.    if (!file)
  67.       return NULL;
  68.    song = read_song(file, type); 
  69.    close_file(file);
  70.    if (song)
  71.       puts(name);
  72.    return song;
  73.    }
  74.  
  75.  
  76. int use_command[16];
  77. int use_extended[16];
  78.  
  79. void analyze_block(b)
  80. struct block *b;
  81.    {
  82.    int i, j;
  83.    struct event *e;
  84.  
  85.    for (i = 0; i < BLOCK_LENGTH; i++)
  86.       {
  87.       int special;
  88.  
  89.       special = 0;
  90.       for (j = 0; j < NUMBER_TRACKS; j++)
  91.          {
  92.          e = &b->e[j][i];
  93.          switch(e->effect)
  94.             {
  95. #if 0
  96.          case 13: /* skip */
  97.             return;
  98.          case 11: /* fastskip */
  99.             return;
  100. #endif
  101.          case 14:
  102.             use_extended[HI(e->parameters)] = TRUE;
  103.             break;
  104.          case 15:
  105.             if (special != 0 && e->parameters != special)
  106.                putchar('!');
  107.             else
  108.                special = e->parameters;
  109.          default:
  110.             use_command[e->effect] = TRUE;
  111.             }
  112.          }
  113.       }
  114.    }
  115.  
  116.  
  117. void analyze_song(song)
  118. struct song *song;
  119.    {
  120.    int i;
  121.  
  122.    for (i = 0; i < NUMBER_SAMPLES; i++)
  123.       {
  124.       if (song->samples[i]->start)
  125.          {
  126.          if (song->samples[i]->finetune)
  127.             printf("Sample %d: finetune is %d\n", 
  128.                i, song->samples[i]->finetune);
  129.          }
  130.       }
  131.    for (i = 0; i < 16; i++)
  132.       {
  133.       use_command[i] = FALSE;
  134.       use_extended[i] = FALSE;
  135.       }
  136.    for (i = 0; i < song->info.maxpat; i++)
  137.       analyze_block(song->info.pblocks+i);
  138.    for (i = 0; i < 16; i++)
  139.       if (use_command[i])
  140.          printf("%3d", i);
  141.    for (i = 0; i < 16; i++)
  142.       if (use_extended[i])
  143.          printf("%3dE", i);
  144.    printf("\n");
  145.    }
  146.  
  147. int main(argc, argv)
  148. int argc;
  149. char **argv;
  150.    {
  151.    int i;
  152.  
  153.    struct song *song;
  154.    int default_type;
  155.  
  156.    default_type = BOTH;
  157.    set_pref_scalar(PREF_TOLERATE, 2);
  158.  
  159.    for (i = 1; i < argc; i++)
  160.       {
  161.       song = do_read_song(argv[i], NEW);
  162.       if (!song && error != NEXT_SONG)
  163.          song = do_read_song(argv[i], OLD);
  164.       if (song)
  165.          {
  166.          analyze_song(song);
  167.          release_song(song);
  168.          }
  169.       }
  170.    return 0;
  171.    }
  172.  
  173.  
  174.  
  175.